<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <title>复选框全选</title>
    <script type="text/javascript">
        $(function(){
            //全选按钮的单击事件
            $("#selectAll").click(function(){
                //获取selectAll这个复选框的checked是否选中属性, 并赋值给所有name叫做cb的复选框
                $("[name='cb']").prop("checked", $("#selectAll").prop("checked"));
            });
        });
    </script>
</head>
<body>
<table border="1" width="800px">
    <tr>
        <td><input type="checkbox" id="selectAll">全选/取消</td>
        <td>id</td>
        <td>姓名</td>
        <td>年龄</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>1</td>
        <td>囚牛</td>
        <td>18</td>

    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>2</td>
        <td>睚眦</td>
        <td>17</td>

    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>3</td>
        <td>嘲风</td>
        <td>16</td>

    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>4</td>
        <td>蒲牢</td>
        <td>15</td>

    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>5</td>
        <td>狻猊（suanni）</td>
        <td>14</td>

    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>6</td>
        <td>赑屃（bixi）</td>
        <td>13</td>

    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>7</td>
        <td>狴犴（bi‘an）</td>
        <td>12</td>

    </tr>

    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>8</td>
        <td>负屃（fu'xi）</td>
        <td>11</td>

    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/></td>

        <td>9</td>
        <td>螭吻（chi'wen）</td>
        <td>10</td>

    </tr>
</table>
</body>
</html>